﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PhysioAssist2Win
{
    /// <summary>
    /// Interaction logic for Anuncios.xaml
    /// </summary>
    public partial class Anuncios : Window
    {
        public Anuncios()
        {
            InitializeComponent();



            //Ajusta posição e tamanho das janelas
            double width = System.Windows.SystemParameters.PrimaryScreenWidth;
            double height = System.Windows.SystemParameters.PrimaryScreenHeight;

            winAnuncios.Width = width;
            winAnuncios.Height = height;

            winAnuncios.Left = 0;
            winAnuncios.Top = 0;



            //Larguras dos Paineis
            pnlEsq.Width = winAnuncios.Width * 0.2;
            pnlEsq.Height = winAnuncios.Height;
            pnlEsq.Margin = new Thickness(20, 20, 0, 0);

            pnlDir.Width = (winAnuncios.Width - 40) * 0.8;
            pnlDir.Height = winAnuncios.Height;
            pnlDir.Margin = new Thickness(20, 20, 0, 0);



            //Carrega anuncios do hospital
            CarregaAnuncios();

        }


        private void CarregaAnuncios()
        {

            WS.WSSoapClient client = new WS.WSSoapClient();
            WS.Anuncio[] lst = client.ListaAnuncios();


            foreach (WS.Anuncio anun in lst)
            {

                Label lbl = new Label();
                TextBlock txt = new TextBlock();

                lbl = new Label(); txt = new TextBlock();
                txt.Text = anun.data.ToShortDateString()  + " - " + NomePessoa(anun.profissional);
                txt.TextWrapping = TextWrapping.Wrap;
                lbl.Content = txt;
                lbl.FontSize = 20;
                lbl.Foreground = Brushes.Gray;
                pnlDir.Children.Add(lbl);


                lbl = new Label(); txt = new TextBlock();
                lbl.Margin = new Thickness(0, 0, 0, 60);
                txt.Text = anun.mensagem;
                txt.TextWrapping = TextWrapping.Wrap;
                lbl.Content = txt;
                lbl.FontSize = 30;
                pnlDir.Children.Add(lbl);

            }



        }



        private string NomePessoa(int id)
        {

            WS.WSSoapClient client = new WS.WSSoapClient();
            WS.Profissional pro = client.GetProfissional(id);
            return pro.nome;


        }

        private void pnlEsq_MouseDown(object sender, MouseButtonEventArgs e)
        {
            winAnuncios.Close();
        }


    }
}
